<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Modules\Car\Entities\CarOrder;

class SunController extends Controller
{
    public function index(){
        $order = CarOrder::query()
            ->where('status',0)
            ->where('created_at','<',now()->subMinutes(30))
            ->get();
        foreach ($order as $item){
            if($item->status==0){
                $item->status = -3;
                if($item->is_coupon==1){
                    $this->recoupon($item->coupon_id);
                }
            }
            $res = $item->save();
        }
        return $order->toArray();
    }
}
